code ="""CREATE DATABASE vancouvertongue;
USE vancouvertongue;
SET storage_engine=innodb;
CREATE TABLE message (
                      messageid INT, 
                      title CHAR(50),
                      PRIMARY KEY (messageid) 
                      );

CREATE TABLE messagebody (
                          id INT AUTO_INCREMENT, 
                          messageid INT, 
                          body CHAR(50),
                          parts INT NOT NULL, 
                          PRIMARY KEY(id)
                          );

CREATE TABLE account (
                      userid CHAR(15), 
                      password CHAR(20) NOT NULL, 
                      email CHAR(55), 
                      level INT NOT NULL DEFAULT 1,  
		      description INT, 
                      avator VARCHAR(150), 
                      PRIMARY KEY (userid),
                      FOREIGN KEY(description) REFERENCES message(messageid) ON DELETE SET NULL 
                      );

CREATE TABLE Block (
                    userid CHAR(15), 
                    blockedby CHAR(15), 
                    expire DATETIME, 
                    message VARCHAR(100), 
                    PRIMARY KEY (userid), 
                    FOREIGN KEY(blockedby) REFERENCES Account(userid) ON DELETE CASCADE, 
                    FOREIGN KEY(userid) REFERENCES Account(userid) ON DELETE CASCADE 
		    );

CREATE TABLE Restaurant (
                         restaurantid INT AUTO_INCREMENT, 
                         ownerid CHAR(15), 
                         restaurantname CHAR(65) NOT NULL, 
                         phone CHAR(15) NOT NULL, 
                         streetname CHAR(65) NOT NULL,
                         city CHAR(20) NOT NULL,
                         website VARCHAR(200), 
                         image VARCHAR(200), 
                         descriptionid INT NOT NULL, 
                         hoursid INT NOT NULL, 
                         category INT NULL DEFAULT 0, 
                         reservation TINYINT(1) NOT NULL DEFAULT false, 
                         rating DOUBLE(2,1) NOT NULL DEFAULT 0, 
                         takeout TINYINT(1) NOT NULL DEFAULT false,
                         PRIMARY KEY(restaurantid), 
                         FOREIGN KEY(ownerid) REFERENCES Account(userid) ON DELETE SET NULL, 
                         FOREIGN KEY(descriptionid) REFERENCES Message(messageid),
			 FOREIGN KEY(hoursid) REFERENCES Message(messageid)
                         );

CREATE TABLE restaurantreq (
                            requestid INT NOT NULL , 
                            restaurantid INT NULL, 
                            date DATETIME NOT NULL,
                            editby CHAR(15),
                            action INT NOT NULL DEFAULT 0,
                            restaurantname CHAR(65) NOT NULL,
                            streetname CHAR(65) NOT NULL,
                            city VARCHAR(20) NOT NULL,
                            image VARCHAR(200), 
                            website VARCHAR(200), 
                            descriptionid INT NOT NULL, 
                            hours INT NOT NULL, 
                            category INT NOT NULL, 
                            phone char(15) NOT NULL, 
                            reservation TINYINT(1) NOT NULL DEFAULT false,
                            takeout TINYINT(1) NOT NULL DEFAULT false,
                            PRIMARY KEY (requestid), 
                            FOREIGN KEY(editby) REFERENCES account(userid) ON DELETE SET NULL,
                            FOREIGN KEY(descriptionid) REFERENCES message(messaged),
			    FOREIGN KEY(hours) REFERENCES message(messaged)
                            );

CREATE TABLE comment (
                      commentid INT NOT NULL,
                      restaurantid INT NOT NULL,
                      messageid INT NOT NULL,
                      userid CHAR(15) NOT NULL,
                      pricelevel DOUBLE, 
                      date DATETIME NOT NULL, 
                      PRIMARY KEY (commentid), 
                      FOREIGN KEY(userid) REFERENCES account(userid) ON DELETE NO ACTION, 
                      FOREIGN KEY(restaurantid) REFERENCES restaurant(restaurantid) ON DELETE CASCADE
                      );

CREATE TABLE rating (
                     userid CHAR(15) NOT NULL,
                     restaurantid int(11) NOT NULL,
                     rating INT NOT NULL DEFAULT 0,
                     PRIMARY KEY (userid,restaurantid), 
                     FOREIGN KEY(userid) REFERENCES Account(userid) ON DELETE NO ACTION, 
                     FOREIGN KEY(restaurantid) REFERENCES Restaurant(restaurantid) ON DELETE CASCADE 
                    );

"""

sList = code.split(";")

for s in sList:
    tmp = ""
    for line in s.split("\n"):
        tmp+=line.lstrip()
        #print line.lstrip()
    print tmp+";"
